home *** CD-ROM | disk | FTP | other *** search
/ Champak 123 / (Vol 123) Jan 13 2011.iso / Games / mofro.swf / scripts / DoInitAction.as
Text File  |  2011-01-13  |  21KB  |  742 lines

  1. raygun = function()
  2. {
  3.    this.onLoad = function()
  4.    {
  5.       this.frame = _root._currentframe;
  6.    };
  7.    this.onEnterFrame = function()
  8.    {
  9.       if(_root._currentframe != this.frame)
  10.       {
  11.          this.removeMovieClip();
  12.       }
  13.       if(!this.watcher)
  14.       {
  15.          if(this.hitTest(_root.hero))
  16.          {
  17.             _root.reallife -= 15;
  18.             _root.life = Math.round(_root.reallife);
  19.             _root.endcheck();
  20.             if(_root[this.shooter]._x < _root.hero._x)
  21.             {
  22.                _root.hero.xchange = 50;
  23.             }
  24.             else
  25.             {
  26.                _root.hero.xchange = -50;
  27.             }
  28.             this.stop();
  29.             this.explode.play();
  30.             this.watcher = true;
  31.          }
  32.          else
  33.          {
  34.             _root.hero.xchange = 0;
  35.          }
  36.       }
  37.    };
  38. };
  39. raygun.prototype = new MovieClip();
  40. Object.registerClass("ray",raygun);
  41. Object.registerClass("thugbullet",raygun);
  42. findlife = function()
  43. {
  44.    this.onLoad = function()
  45.    {
  46.       this.name = this._name.slice(-1);
  47.       this.checker = this._name.slice(-2,-1);
  48.       this.checker = Number(this.checker);
  49.       if(this.checker > 0)
  50.       {
  51.          this.name = this._name.slice(-2);
  52.       }
  53.       this.name = Number(this.name);
  54.       if(!_root.lifearray[this.name])
  55.       {
  56.          this.gotoAndStop(2);
  57.       }
  58.       delete this.checker;
  59.    };
  60.    this.onEnterFrame = function()
  61.    {
  62.       if(this.hitTest(_root.hero))
  63.       {
  64.          _root.reallife += 15;
  65.          if(_root.reallife > 100)
  66.          {
  67.             _root.reallife = 100;
  68.          }
  69.          _root.life = Math.round(_root.reallife);
  70.          _root.lifearray[this.name] = false;
  71.          _root.score += 6;
  72.          this.gotoAndStop(2);
  73.          delete this.onEnterFrame();
  74.       }
  75.    };
  76. };
  77. findlife.prototype = new MovieClip();
  78. Object.registerClass("extralife",findlife);
  79. alienmove = function()
  80. {
  81.    this.onLoad = function()
  82.    {
  83.       _this._xscale = 100;
  84.       this._yscale = 100;
  85.       high = 50;
  86.       h_width = 25;
  87.       this.move = -2;
  88.       this.x = this._x;
  89.       _root.maptest(this._name);
  90.    };
  91.    this.onEnterFrame = function()
  92.    {
  93.       if(Math.abs(this._x - _root.hero._x) < 15)
  94.       {
  95.          this.move = 0;
  96.          this.stop();
  97.          if(this._x > hero._x)
  98.          {
  99.             this._xscale = 100;
  100.          }
  101.          else
  102.          {
  103.             this._xscale = -100;
  104.          }
  105.       }
  106.       else
  107.       {
  108.          if(this.hitTest(_root.hero))
  109.          {
  110.             _root.reallife -= 0.5;
  111.             _root.life = Math.round(_root.reallife);
  112.             _root.endcheck();
  113.          }
  114.          if(this._x > this.maxx)
  115.          {
  116.             if(_root.hero._x > this._x)
  117.             {
  118.                this.move = 0;
  119.                this.stop();
  120.             }
  121.             else
  122.             {
  123.                this._xscale = 100;
  124.                this.move = -2;
  125.             }
  126.          }
  127.          else if(this._x < this.minx)
  128.          {
  129.             if(_root.hero._x < this._x)
  130.             {
  131.                this.move = 0;
  132.                this.stop();
  133.             }
  134.             else
  135.             {
  136.                this._xscale = -100;
  137.                this.move = 2;
  138.             }
  139.          }
  140.          else if(_root.hero._x > this._x)
  141.          {
  142.             this._xscale = -100;
  143.             this.move = 2;
  144.             this.play();
  145.          }
  146.          else if(_root.hero._x < this._x)
  147.          {
  148.             this._xscale = 100;
  149.             this.move = -2;
  150.             this.play();
  151.          }
  152.       }
  153.       this.x += this.move;
  154.       this._x = this.x;
  155.    };
  156. };
  157. alienmove.prototype = new MovieClip();
  158. Object.registerClass("alien",alienmove);
  159. spikewatch = function()
  160. {
  161.    this.onEnterFrame = function()
  162.    {
  163.       if(!this.timeon)
  164.       {
  165.          if(this.hitTest(_root.hero))
  166.          {
  167.             _root.hero._visible = 0;
  168.             this.gotoAndStop(2);
  169.             this.colour = _root.herocolor.getRGB();
  170.             this.impalecolour = new Color(this.impile2);
  171.             this.impalecolour.setRGB(this.colour);
  172.             this.timeon = true;
  173.          }
  174.       }
  175.       else
  176.       {
  177.          _root.reallife = 0;
  178.          _root.life = 0;
  179.          this.timer = this.timer + 1;
  180.          if(this.timer > 60)
  181.          {
  182.             _root.life = 0;
  183.             _root.impile.gotoAndStop(1);
  184.             _root.endcheck();
  185.          }
  186.       }
  187.    };
  188. };
  189. spikewatch.prototype = new MovieClip();
  190. Object.registerClass("spikes",spikewatch);
  191. paniwatch = function()
  192. {
  193.    this.onLoad = function()
  194.    {
  195.       this.gotoAndPlay(Math.round(Math.random() * 20));
  196.    };
  197.    this.onEnterFrame = function()
  198.    {
  199.       if(this.hitTest(_root.hero))
  200.       {
  201.          _root.reallife -= 0.5;
  202.          _root.life = Math.round(_root.reallife);
  203.          _root.endcheck();
  204.       }
  205.    };
  206. };
  207. paniwatch.prototype = new MovieClip();
  208. Object.registerClass("pani",paniwatch);
  209. swarm = function()
  210. {
  211.    this.onLoad = function()
  212.    {
  213.       this.swarmcolour = new Color(this.swarm);
  214.       this.shapeX = this._x;
  215.       this.shapeY = this._y;
  216.       this.targetX = 0;
  217.       this.targetY = 0;
  218.       this.oldTargetX = 0;
  219.       this.FlockX = Math.random() * 200 - 100;
  220.       this.FlockY = Math.random() * 200 - 100;
  221.       this.move = true;
  222.    };
  223.    this.onEnterFrame = function()
  224.    {
  225.       if(this.move)
  226.       {
  227.          if(!_root.homing)
  228.          {
  229.             this.targetX = _root.hero._x;
  230.             this.targetY = _root.hero._y;
  231.          }
  232.          else if(!this.run)
  233.          {
  234.             this.run = true;
  235.             this.targetX = Math.random() * 400;
  236.             this.targetY = Math.random() * 700;
  237.          }
  238.          else
  239.          {
  240.             this.targetX += 100 - Math.random() * 200;
  241.             this.targetY += 100 - Math.random() * 200;
  242.          }
  243.          this.distX = this.targetX - this.shapeX + this.FlockX;
  244.          this.distY = this.targetY - this.shapeY + this.FlockY;
  245.          if(this.targetX == this.oldTargetX && Math.random() > 0.9)
  246.          {
  247.             this.FlockX = Math.random() * 100 - 50;
  248.             this.FlockY = Math.random() * 100 - 50;
  249.          }
  250.          else if(this.targetX != this.oldTargetX && Math.random() > 0.8)
  251.          {
  252.             this.FlockX = Math.random() * 400 - 200;
  253.             this.FlockY = Math.random() * 400 - 200;
  254.          }
  255.          this.shapeX = Math.round(this.shapeX + this.DistX / 15);
  256.          this.shapeY = Math.round(this.shapeY + this.DistY / 15);
  257.          _root.maptest(this._name);
  258.          if(this.shapeX - this._width / 2 < this.minx)
  259.          {
  260.             this.shapeX = this.minx + this._width / 2;
  261.          }
  262.          else if(this.shapeX + this._width / 2 > this.maxx)
  263.          {
  264.             this.shapeX = this.maxx - this._width / 2;
  265.          }
  266.          if(this.shapeY + this._height / 2 > this.miny)
  267.          {
  268.             this.shapeY = this.miny - this._height / 2;
  269.          }
  270.          else if(this.shapeY - this._height / 2 < this.maxy)
  271.          {
  272.             this.shapeY = this.maxy + this._height / 2;
  273.          }
  274.          this._x = this.shapeX;
  275.          this._y = this.shapeY;
  276.          this.oldTargetX = this.targetX;
  277.          if(this.hitTest(_root.hero))
  278.          {
  279.             this.swarmcolour.setRGB(10682625);
  280.             _root.reallife -= 0.5;
  281.             _root.life = Math.round(_root.reallife);
  282.             _root.endcheck();
  283.          }
  284.          else
  285.          {
  286.             this.swarmcolour.setRGB(0);
  287.          }
  288.       }
  289.    };
  290. };
  291. swarm.prototype = new MovieClip();
  292. Object.registerClass("swarmer",swarm);
  293. bulletmove = function()
  294. {
  295.    this.frame = _root._currentframe;
  296.    this.swarmno = _root.swarmarray[scene][0];
  297.    if(this.swarmno == "alien")
  298.    {
  299.       this.swarmno = 0;
  300.    }
  301.    if(_root.bulletnum == 1)
  302.    {
  303.       this.onLoad = function()
  304.       {
  305.          _root.maptest(this._name);
  306.          this.speed = 20;
  307.       };
  308.       this.onEnterFrame = function()
  309.       {
  310.          if(_root._currentframe != this.frame)
  311.          {
  312.             this.removeMovieClip();
  313.          }
  314.          this._x += this.speed * this.x;
  315.          this._y += this.speed * this.y;
  316.          this.speed += 1;
  317.          if(this._x < this.minx || this._x > this.maxx || this._y > this.miny || this._y < this.maxy)
  318.          {
  319.             this.removeMovieClip();
  320.          }
  321.          if(this.swarmno == 0)
  322.          {
  323.             if(this.hitTest(_root.alien))
  324.             {
  325.                _root.alien.attachMovie("blowup","blowup",10000);
  326.                _root.enemies += 1;
  327.                _root.alien.gotoAndStop("off");
  328.                _root.score += 10;
  329.                _root.swarmarray[_root.scene] = 0;
  330.                this.removeMovieClip();
  331.             }
  332.          }
  333.          else
  334.          {
  335.             i = 1;
  336.             while(i <= this.swarmno)
  337.             {
  338.                if(this.hitTest(_root["swarm" + i]))
  339.                {
  340.                   if(_root["swarm" + i].move)
  341.                   {
  342.                      _root.enemies += 1;
  343.                      _root["swarm" + i].move = false;
  344.                      _root["swarm" + i].attachMovie("blowup","blowup",10000);
  345.                      _root.swarmarray[_root.scene][0] -= 1;
  346.                      _root.score += 10;
  347.                      this.removeMovieClip();
  348.                   }
  349.                }
  350.                i++;
  351.             }
  352.          }
  353.       };
  354.    }
  355.    else if(_root.bulletnum == 2)
  356.    {
  357.       this.onLoad = function()
  358.       {
  359.          this.speed = 30;
  360.          this.timer = 100;
  361.          this.mx = this._x;
  362.          this.my = this._y;
  363.       };
  364.       this.onEnterFrame = function()
  365.       {
  366.          if(_root._currentframe != this.frame)
  367.          {
  368.             this.removeMovieClip();
  369.          }
  370.          this.timer -= 2;
  371.          if(this.timer <= 5)
  372.          {
  373.             this.removeMovieClip();
  374.          }
  375.          else
  376.          {
  377.             this._alpha = this.timer;
  378.          }
  379.          _root.maptest(this._name);
  380.          this.mx += this.speed * this.x;
  381.          this.my += this.speed * this.y;
  382.          if(this.mx < this.minx || this.mx > this.maxx)
  383.          {
  384.             this.x *= -1;
  385.             this.mx = this._x;
  386.          }
  387.          else
  388.          {
  389.             this._x = this.mx;
  390.          }
  391.          if(this.my > this.miny || this.my < this.maxy)
  392.          {
  393.             this.y *= -1;
  394.             this.my = this._y;
  395.          }
  396.          else
  397.          {
  398.             this._y = this.my;
  399.          }
  400.          if(this.hitTest(_root.alien))
  401.          {
  402.             _root.enemies += 1;
  403.             _root.alien.attachMovie("blowup","blowup",10000);
  404.             _root.alien.gotoAndStop("off");
  405.             _root.swarmarray[_root.scene] = 0;
  406.             _root.score += 10;
  407.             this.removeMovieClip();
  408.          }
  409.          i = 1;
  410.          while(i <= this.swarmno)
  411.          {
  412.             if(this.hitTest(_root["swarm" + i]))
  413.             {
  414.                if(_root["swarm" + i].move)
  415.                {
  416.                   _root.enemies += 1;
  417.                   _root["swarm" + i].move = false;
  418.                   _root["swarm" + i].attachMovie("blowup",blowup,10000);
  419.                   _root.swarmarray[_root.scene][0] -= 1;
  420.                   _root.score += 10;
  421.                   this.removeMovieClip();
  422.                }
  423.             }
  424.             i++;
  425.          }
  426.       };
  427.    }
  428.    else if(_root.bulletnum == 3)
  429.    {
  430.       this.onLoad = function()
  431.       {
  432.          this.shapeX = this._x;
  433.          this.shapeY = this._y;
  434.          this.targetX = 0;
  435.          this.targetY = 0;
  436.          this.move = true;
  437.          _root.homing = true;
  438.       };
  439.       this.onUnload = function()
  440.       {
  441.          delete _root.homing;
  442.       };
  443.       this.onEnterFrame = function()
  444.       {
  445.          if(this.move)
  446.          {
  447.             if(_root._currentframe != this.frame)
  448.             {
  449.                this.removeMovieClip();
  450.             }
  451.             if(this.swarmno == 0)
  452.             {
  453.                this.targetX = _root.alien._x;
  454.                this.targetY = _root.alien._y;
  455.             }
  456.             else
  457.             {
  458.                i = 1;
  459.                while(i <= this.swarmno)
  460.                {
  461.                   this.targetX = _root["swarm" + i]._x;
  462.                   this.targetY = _root["swarm" + i]._y;
  463.                   i++;
  464.                }
  465.             }
  466.             this.distX = this.targetX - this.shapeX;
  467.             this.distY = this.targetY - this.shapeY;
  468.             this.shapeX = Math.round(this.shapeX + this.DistX / 10);
  469.             this.shapeY = Math.round(this.shapeY + this.DistY / 10);
  470.             _root.maptest(this._name);
  471.             if(this.shapeX < this.minx || this.shapeX > this.maxx || his.shapeY > this.miny || this.shapeY < this.maxy)
  472.             {
  473.                this.attachMovie("blowup","blowup",1000);
  474.                this.move = false;
  475.             }
  476.             this._x = this.shapeX;
  477.             this._y = this.shapeY;
  478.             if(this.swarmno == 0)
  479.             {
  480.                if(this.hitTest(_root.alien))
  481.                {
  482.                   _root.enemies += 1;
  483.                   _root.alien.attachMovie("blowup",blowup,10000);
  484.                   _root.alien.gotoAndStop("off");
  485.                   _root.score += 10;
  486.                   _root.swarmarray[_root.scene] = 0;
  487.                   this.removeMovieClip();
  488.                }
  489.             }
  490.             else
  491.             {
  492.                i = 1;
  493.                while(i <= this.swarmno)
  494.                {
  495.                   if(_root["swarm" + i].move)
  496.                   {
  497.                      if(this.hitTest(_root["swarm" + i]))
  498.                      {
  499.                         _root.enemies += 1;
  500.                         this.removeMovieClip();
  501.                         _root["swarm" + i].move = false;
  502.                         _root["swarm" + i].attachMovie("blowup",blowup,10000);
  503.                         _root.score += 10;
  504.                         _root.swarmarray[_root.scene][0] -= 1;
  505.                      }
  506.                   }
  507.                   i++;
  508.                }
  509.             }
  510.          }
  511.       };
  512.    }
  513. };
  514. bulletmove.prototype = new MovieClip();
  515. Object.registerClass("bullet",bulletmove);
  516. doorcheck2 = function()
  517. {
  518.    this.takeoutwall = function()
  519.    {
  520.       this.gotoAndStop(2);
  521.       _root["wall" + _root.keywall].gotoAndStop(2);
  522.       _root["wall" + _root.keywall].maxx = 0;
  523.       _root["wall" + _root.keywall].minx = 0;
  524.       _root["wall" + _root.keywall].maxy = 0;
  525.       _root["wall" + _root.keywall].miny = 0;
  526.    };
  527.    this.rununlockcheck = function()
  528.    {
  529.       if(_root.door2[this.name][1] == _root.currentitem[1])
  530.       {
  531.          this.gotoAndStop(2);
  532.          _root.phatman1.removeMovieClip();
  533.          _root.attachMovie("phatmanoff","phatmanoff1",95);
  534.          _root.phatmanoff1._x = _root.phatlist[_root.scene][0];
  535.          _root.phatmanoff1._y = _root.phatlist[_root.scene][1];
  536.          _root.score += 25;
  537.          _root.phatnum += 1;
  538.          _root.removeitem();
  539.          _root.item = "carrying " + _root.currentitem[0];
  540.          _root.door2[this.name][0] = false;
  541.          this.takeoutwall();
  542.       }
  543.       else if(!this.first)
  544.       {
  545.          this.first = true;
  546.          _root.attachMovie("speech","speech1",2000);
  547.          _root.speech1.gotoAndStop("item");
  548.          _root.speech1._x = _root.phatman1._x;
  549.          _root.speech1._y = _root.phatman1._y + 40;
  550.          _root.speech1.itemname = _root.door2[this.name][1];
  551.       }
  552.    };
  553.    this.onLoad = function()
  554.    {
  555.       this.name = this._name.slice(-1);
  556.       this.checker = this._name.slice(-2,-1);
  557.       this.checker = Number(this.checker);
  558.       if(this.checker > 0)
  559.       {
  560.          this.name = this._name.slice(-2);
  561.       }
  562.       this.name = Number(this.name);
  563.       delete this.checker;
  564.       if(!_root.door2[this.name][0])
  565.       {
  566.          this.takeoutwall();
  567.       }
  568.       else
  569.       {
  570.          _root.attachMovie("phatman","phatman1",95);
  571.          _root.phatman1._x = _root.phatlist[_root.scene][0];
  572.          _root.phatman1._y = _root.phatlist[_root.scene][1];
  573.       }
  574.    };
  575.    this.onEnterFrame = function()
  576.    {
  577.       if(this.hitTest(_root.hero))
  578.       {
  579.          this.rununlockcheck();
  580.       }
  581.       else if(this.first)
  582.       {
  583.          this.first = false;
  584.          _root.speech1.removeMovieClip();
  585.       }
  586.    };
  587. };
  588. doorcheck2.prototype = new MovieClip();
  589. Object.registerClass("door2",doorcheck2);
  590. doorcheck = function()
  591. {
  592.    this.rununlockcheck = function()
  593.    {
  594.       if(_root.doors[this.name][4] == _root.currentitem[1])
  595.       {
  596.          _root.score += 3;
  597.          this.gotoAndStop("open");
  598.          _root.doornum += 1;
  599.          _root.removeitem();
  600.          _root.doors[this.name][3] = false;
  601.          this.otherdoor = _root.doors[this.name][1];
  602.          _root.doors[this.otherdoor][3] = false;
  603.          delete otherdoor;
  604.       }
  605.       else if(!this.first)
  606.       {
  607.          this.first = true;
  608.          _root.attachMovie("speech","speech1",2000);
  609.          _root.speech1.gotoAndStop(_root.doors[this.name][4]);
  610.          _root.speech1.follow = true;
  611.          _root.speech1._x = _root.hero._x;
  612.          _root.speech1._y = _root.hero._y;
  613.       }
  614.    };
  615.    this.rundoorcheck = function()
  616.    {
  617.       if(!_root.doors[this.name][3])
  618.       {
  619.          _root.scenechange(this.name);
  620.       }
  621.    };
  622.    this.onLoad = function()
  623.    {
  624.       this.checker = this._name.slice(-2,-1);
  625.       this.checker = Number(this.checker);
  626.       this.checker2 = this._name.slice(-3,-2);
  627.       this.checker2 = Number(this.checker2);
  628.       if(this.checker2 > 0)
  629.       {
  630.          this.name = this._name.slice(-3);
  631.       }
  632.       else if(this.checker > 0)
  633.       {
  634.          this.name = this._name.slice(-2);
  635.       }
  636.       else
  637.       {
  638.          this.name = this._name.slice(-1);
  639.       }
  640.       delete checker;
  641.       delete checker2;
  642.       this.name = Number(this.name);
  643.       if(_root.doors[this.name][3])
  644.       {
  645.          if(_root.doors[this.name][4] == "key")
  646.          {
  647.             this.gotoAndStop("key");
  648.          }
  649.          else if(_root.doors[this.name][4] == "keycard")
  650.          {
  651.             if(_root.doors[this.name][2] < 0)
  652.             {
  653.                this.gotoAndStop("keycardleft");
  654.             }
  655.             else
  656.             {
  657.                this.gotoAndStop("keycardright");
  658.             }
  659.          }
  660.          else if(_root.doors[this.name][4] == "hallpass")
  661.          {
  662.             this.gotoAndStop(2);
  663.          }
  664.          else
  665.          {
  666.             this.gotoAndStop("locked");
  667.          }
  668.       }
  669.       else
  670.       {
  671.          this.gotoAndStop(1);
  672.       }
  673.    };
  674.    this.onEnterFrame = function()
  675.    {
  676.       if(this.hitTest(_root.hero))
  677.       {
  678.          if(_root.doors[this.name][3])
  679.          {
  680.             this.rununlockcheck();
  681.          }
  682.          if(Math.abs(_root.hero._x - this._x) < 10)
  683.          {
  684.             if(Math.abs(hero._y - this._y) < 25)
  685.             {
  686.                this.rundoorcheck();
  687.             }
  688.          }
  689.       }
  690.       else if(this.first)
  691.       {
  692.          this.first = false;
  693.          _root.speech1.removeMovieClip();
  694.       }
  695.    };
  696. };
  697. doorcheck.prototype = new MovieClip();
  698. Object.registerClass("door",doorcheck);
  699. itemcheck = function()
  700. {
  701.    this.onLoad = function()
  702.    {
  703.       this.name = this._name.slice(-1);
  704.       this.checker = this._name.slice(-2,-1);
  705.       this.checker = Number(this.checker);
  706.       if(this.checker > 0)
  707.       {
  708.          this.name = this._name.slice(-2);
  709.       }
  710.       this.name = Number(this.name);
  711.       delete this.checker;
  712.       if(!_root.items[this.name][0])
  713.       {
  714.          this.attachMovie(_root.items[this.name][1],"inside",1);
  715.          if(_root.items[this.name][0] != false)
  716.          {
  717.             this.onEnterFrame = function()
  718.             {
  719.                if(_root.items[this.name][0] != false)
  720.                {
  721.                   if(Key.isDown(32) && this.pressed == false)
  722.                   {
  723.                      this.pressed = true;
  724.                      if(this.hitTest(_root.hero))
  725.                      {
  726.                         _root.pickup(this.name);
  727.                         _root.notfired = false;
  728.                      }
  729.                   }
  730.                   else if(!Key.isDown(32))
  731.                   {
  732.                      this.pressed = false;
  733.                   }
  734.                }
  735.             };
  736.          }
  737.       }
  738.    };
  739. };
  740. itemcheck.prototype = new MovieClip();
  741. Object.registerClass("item",itemcheck);
  742.